package org.example;

import org.example.extension.factoryBean.SomeComplexObject;
import org.example.factoryBean.Client;
import org.example.lazy.LazyBean;
import org.example.lazy.LazyBeanWrapper;
import org.example.lazy.LazyBeanWrapper2;
import org.example.objectFactory.SingletonBean;
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ConfigurableApplicationContext;

@SpringBootApplication
public class Application {
    public static void main(String[] args) throws Exception {

        ConfigurableApplicationContext context= SpringApplication.run(Application.class, args);

        System.out.println("容器已启动完成！");

        //验证一：getBean会调用lazyBean实例化（构造函数）和初始化方法
        //context.getBean(LazyBean.class);

        //验证二：使用@Autowired注入的LazyBean
        //LazyBeanWrapper lazyBeanWrapper=context.getBean(LazyBeanWrapper.class);
        //lazyBeanWrapper.doSomething();

        //验证三：使用ObjectFactory注入的LazyBean
        //LazyBeanWrapper2 lazyBeanWrapper=context.getBean(LazyBeanWrapper2.class);
        //lazyBeanWrapper.doSomething();

        // 验证四：使用FactoryBean
        //Client client=context.getBean(Client.class);
        //client.doSomething();

        // 验证五：ObjectFactory注入的PrototypeBean
        /*SingletonBean singletonBean=context.getBean(SingletonBean.class);
        singletonBean.doSomething();
        singletonBean.doSomething();*/

        // 验证六：使用FactoryBean
        //context.getBean(SomeComplexObject.class);
    }
}